home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / 7arte (imagem pequena).ifs < prev    next >
Encoding:
Text File  |  2004-05-07  |  11.0 KB  |  309 lines

  1. // GETINFO SCRIPTING
  2. // www.7arte.net(imagem pequena)
  3. //Script feito pelo O Guardiπo versπo 2.0 Beta 2
  4. //23-02-2004
  5. //03-03-2004 corrigido: a procura agora encontra os filmes na lingua original e em portugues
  6. //04-03-2004 corrigido: problema com espaτo em branco duraτπo
  7. //06-03-2004 corrigido: descriτ⌡es dos filmes que se encontrem em multilinha ja da para importar sem "cortes"
  8. //06-03-2004 corrigido: existia um erro por vezes nos actores que estß agora corrigido
  9. //17-03-2004 corrigido: mudei o anonymization.net para o triumphpc.com e este script ja funciona novamente
  10. //19-03-2004 corrigido: caso nπo houver comentarios o campo fica em branco
  11. //19-03-2004 adicionado: agora as capas dos filme sπo importadas apartir do site do Amazon (limitei-me a copiar a funτπo GetMoviePicture do script IMDB (large pic) e fiz umas pequenas alteraτ⌡es para ser compativel com este script)
  12. //           atenτπo nπo funciona em todos os filme
  13. //19-03-2004 A listagem dos filme foi reestruturada, mas continuam a parecer filmes repetidos porque a procura Θ feita duas vezes, procura pelo nome original e procurar pelo nome traduzido. Talvez eu corriga esse bug mais tarde.
  14. //25-03-2004 a pontuaτπo foi corrigida ja aparece novamente e o valor nπo Θ truncado, mas sim arredondado
  15. //04-04-2004 Corrigido: Por vezes o nome do realizador nπo aparecia
  16. //04-04-2004 Agora os nomes dos filmes em PortuguΩs jß nπo aparecem todas em maiusculas
  17. //07-04-2004 Corrigido:Em alguns filme mais recente o nome em portugues aparecia com espaτo em branco antes do nome
  18. //07-05-2004 Corrigido: Devido a actualizaτ⌡es no 7 arte o meu script ja nπo funcionava
  19.  
  20. (***************************************************
  21.  *  For use with Ant Movie Catalog 3.4.0           *
  22.  *  www.antp.be/software/moviecatalog              *
  23.  *                                                 *
  24.  *  The source code of the script can be used in   *
  25.  *  another program only if full credits to        *
  26.  *  script author and a link to Ant Movie Catalog  *
  27.  *  website are given in the About box or in       *
  28.  *  the documentation of the program               *
  29.  *                                                 *
  30.  *  Please dont remove credits                     *
  31.  *  Reportem os erros para bruno_mga@hotmail.com   *
  32.  ***************************************************)
  33. program arte;
  34. const
  35.   BaseAddress = 'www.7arte.net/';
  36.   ManualPictureSelect = True;
  37.   ExternalPictures = False;
  38. var
  39.   MovieName: string;
  40.  
  41. function UpFirstLetterWord(texto:string):string; //Function Made By O Guardiπo
  42. var espaco:integer;
  43.  sst:string;
  44. begin
  45. texto:=AnsiUpFirstLetter(AnsiLowerCase(texto));
  46. repeat
  47.     espaco:=Pos(' ',texto);
  48.     sst:=AnsiUpperCase(Copy(texto,espaco+1,1));
  49.     texto:=Copy(texto,1,espaco-1)+'/|\'+sst+Copy(texto,espaco+2,length(texto));
  50. until Pos(' ',texto)=0;
  51. texto := StringReplace(texto, '/|\', ' ');
  52. if Copy(texto,1,1)=' ' then//se a 1║ pos Θ espaτo
  53.   texto:=Copy(texto,2,length(texto));
  54. result:=texto;
  55. end;
  56.  
  57. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  58. var
  59.   i: Integer;
  60. begin
  61.   result := -1;
  62.   if StartAt < 0 then
  63.     StartAt := 0;
  64.   for i := StartAt to List.Count-1 do
  65.     if Pos(Pattern, List.GetString(i)) <> 0 then
  66.     begin
  67.       result := i;
  68.       Break;
  69.     end;
  70. end;
  71. function HTMLRemove(Value: String): String;
  72. begin
  73.   HTMLDecode(Value);
  74.   HTMLRemoveTags(Value);
  75.   Value := Trim(Value);
  76.   result := Value;
  77. end;
  78. procedure AnalyzeFilmPage(Address: String);
  79. var
  80.   Page : TStringList;
  81.   Line, Value : string;
  82.   LineNr, BeginPos, EndPos: Integer;
  83.   AllTitles: TStringList;
  84. begin
  85.   Page := TStringList.Create;
  86.   Page.Text := GetPage('http://triumphpc.com/cgi-bin/nph-proxy.cgi/000000A/http/'+Address);
  87.   SetField(fieldURL, Address);
  88.  
  89.   //para continuar deve ser diferente destas mensagens
  90.   if (FindLine('SERVIDOR EM EXCESSO DE CARGA', Page, 0)<>-1) and (FindLine('POR FAVOR TENTE MAIS TARDE.', Page, 0)<>-1) then
  91.   showmessage('Servidor encontra-se indisponivel.')
  92.   else
  93.   begin
  94.   //nome traduzido do filme
  95.   LineNr := FindLine('<FONT FACE="Arial,Helvetica"><FONT SIZE=+1>', Page, 0);
  96.   Value := Page.GetString(LineNr);
  97.   value:=HTMLRemove(value);
  98.   Value:=UpFirstLetterWord(Value);
  99.   SetField(fieldTranslatedTitle, Value);
  100.  
  101.   //nome original do filme
  102.   value:= Page.GetString(LineNr+1);
  103.   Value := HTMLRemove(Value);
  104.   SetField(fieldOriginalTitle, Value);
  105.  
  106.   //pontuaτπo
  107.   LineNr := FindLine('<FONT SIZE=-1 FACE="Arial,Helvetica"><B>', Page, 0);
  108.   Value := Page.GetString(LineNr);
  109.   value:=HTMLRemove(value);
  110.   if (pos('.',value)<>-1) then
  111.    BeginPos:=StrToInt(copy(value,3,1),0);
  112.    if BeginPos>4 then
  113.      value:=IntToStr(1+StrToInt(Copy(value,1,1),0))
  114.   else
  115.   value:=Copy(value,1,1);
  116.   SetField(fieldRating, Value);
  117.  
  118.   //realizador
  119.   LineNr := FindLine('>Realizador:</', Page, 0);
  120.   Value := HTMLRemove(Page.GetString(LineNr));
  121.   value:=Copy(value,13,length(value));
  122.   SetField(fieldDirector, Value);
  123.  
  124.   //actores
  125.   Line:='';
  126. //  LineNr := FindLine('<B>╗</B> <a>', Page, 0);
  127.   LineNr := FindLine('<B>Actores:</B><BR><FONT Size=-1>', Page, 0);
  128.   lineNr:=lineNr+1;
  129.   repeat
  130.   value:=Page.GetString(LineNr);
  131.   if line<>'' then line:=line+', ';  // virgula entre cada nome
  132.   Line:=line+Copy(HTMLRemove(value),3,length(value));
  133.   lineNr:=lineNr+1;
  134.   value:=Page.GetString(LineNr);
  135. //  until  pos('<B>╗</B> <a>',value)=0;
  136.   until pos('</FONT></TD>',value)<> 0;
  137.   SetField(fieldActors, Line);
  138.  
  139.   //ano
  140.   LineNr := FindLine('><B>Ano:</B>', Page, 0);
  141.   value:=Copy(HTMLRemove(Page.GetString(LineNr)),6,length(value));
  142.   SetField(fieldYear, value);
  143.  
  144.   //duraτπo
  145.   LineNr := FindLine('<B>Duraτπo:</B> <FONT SIze=-1>', Page, 0);
  146.   value:=HTMLRemove(Page.GetString(LineNr));
  147.   Value := StringReplace(Value, 'Duraτπo: ', '');
  148.   Value := StringReplace(Value, ' minutos', '');
  149.   SetField(fieldLength, value);
  150.  
  151.   //genero
  152.   LineNr := FindLine('<B>GΘnero:</B> <FONT SIze=-1>', Page, 0);
  153.   value:=HTMLRemove(Page.GetString(LineNr));
  154.   Value := StringReplace(Value, 'GΘnero: ', '');
  155.   SetField(fieldCategory, value);
  156.  
  157.   //paφs
  158.   LineNr := FindLine('<B>Paφs de Origem:</B> <FONT SIze=-1>', Page, 0);
  159.   value:=HTMLRemove(Page.GetString(LineNr));
  160.   Value := StringReplace(Value, 'Paφs de Origem: ', '');
  161.   SetField(fieldCountry, value);
  162.   
  163.   //descriτπo
  164.   LineNr := FindLine('<B>Sinopse:</B><BR>', Page, 0);
  165.   if LineNr<>-1 then
  166.   begin
  167.   value:='';
  168.   repeat
  169.   LineNr:=LineNr+1;
  170.   value:=value+Page.GetString(LineNr);
  171.   until Pos('</TD>', Page.GetString(LineNr)) <> 0; //ate encontrar o </Td>
  172.   value:=HTMLRemove(value);
  173.   Value := StringReplace(Value, ' [ www.7arte.net ]', '');
  174.   SetField(fieldDescription, value);
  175.   end;
  176.  
  177.   // Get Picture
  178.   LineNr := FindLine('/imagens/filmes/', Page, 0);
  179.   if LineNr > -1 then
  180.   begin
  181.     value := Page.GetString(LineNr);
  182.     BeginPos := pos('src="', value)+5;
  183.     EndPos := pos('.jpg', value);
  184.   if endpos=0 then
  185.     EndPos := pos('.gif', value);
  186.     Value :=copy(value, BeginPos,4+EndPos-BeginPos);
  187.     GetPicture(Value, False);
  188.   end;
  189.  
  190.   //obter imdb link
  191.   LineNr := FindLine('imdb.com', Page, 0);
  192.   if LineNr > -1 then
  193.   begin
  194.      value := Page.GetString(LineNr);
  195.      beginpos:=pos('img width',value)-4;
  196.      value:=Copy(value,1,beginpos);
  197.      beginpos:=pos('href',value)+6;
  198.      value:=Copy(value,beginpos,length(value));
  199.      Value := StringReplace(Value, 'http://triumphpc.com/cgi-bin/nph-proxy.cgi/000000A/http/', '');
  200.      value:='http://'+value;
  201.  
  202.   //imagem pequena imdb
  203.   Page.Text := GetPage(value);
  204.  
  205.   // Picture - copiado do IMDB (pic)
  206.   LineNr := FindLine('<img alt="cover" align="left" src="http://ia.imdb.com/media/imdb/', Page, 0);
  207.   if LineNr < 0 then
  208.     LineNr := FindLine('<img alt="cover" align="left" src="http://posters.imdb.com/', Page, 0);
  209.   if LineNr < 0 then
  210.     LineNr := FindLine('<img alt="cover" align="left" src="http://images.amazon.com/', Page, 0);
  211.   if LineNr > -1 then
  212.   begin
  213.     Line := Page.GetString(LineNr);
  214.     BeginPos := pos('src="', Line) + 4;
  215.     Delete(Line, 1, BeginPos);
  216.     EndPos := pos('"', Line);
  217.     Value := copy(Line, 1, EndPos - 1);
  218.     GetPicture(Value, False);
  219.   end;
  220.  
  221.  
  222.  
  223.   end;
  224.   
  225.   
  226. end;
  227. end;
  228.  
  229. procedure AnalyzePage(Address,Address2: string);
  230. var
  231.   Page: TStringList;
  232.   LineNr, StartPos, EndPos: Integer;
  233.   Line: string;
  234.   x:integer;
  235.   MovieAddress, findMovieName,linedown : string;
  236. begin
  237.   PickTreeClear;
  238.   Page := TStringList.Create;
  239.   Page.Text := GetPage(Address);
  240.  
  241.  
  242.   if (pos('Resultados Encontrados', Page.Text)>0) then   //search portuguese
  243.   begin
  244.     LineNr :=0;
  245.      repeat
  246.       LineNr := FindLine('/cgi-bin/f_filme.pl?codigo=', Page, LineNr);
  247.       If LineNr >0 Then Begin
  248.         Line := Page.GetString(LineNr);
  249.         StartPos := pos('cgi-bin/f_filme.pl?codigo=', Line);
  250.         EndPos := pos(')">',Line)-1;
  251.         MovieAddress :=  copy(Line, StartPos, EndPos - StartPos);
  252.         StartPos := EndPos + 15;
  253.         StartPos :=  EndPos+4;
  254.         endpos:=pos('</A><BR>',Line);
  255.         Line:=Copy(Line,startpos,endpos);
  256.         findmoviename:=HTMLRemove(Line);
  257.         HTMLRemoveTags(FindMovieName);
  258.         HTMLDecode(FindMovieName);
  259.         PickTreeAdd(FindMovieName, BaseAddress + MovieAddress);
  260.         LineNr := LineNr + 1;
  261.       End;
  262.     until (LineNr<1);
  263.     end;
  264.  
  265.     Page.Text := GetPage(Address2);
  266.  
  267.   if (pos('Resultados Encontrados', Page.Text)>0) then   //search portuguese
  268.   begin
  269.     LineNr :=0;
  270.     repeat
  271.       LineNr := FindLine('/cgi-bin/f_filme.pl?codigo=', Page, LineNr);
  272.       If LineNr >0 Then Begin
  273.         Line := Page.GetString(LineNr);
  274.         StartPos := pos('cgi-bin/f_filme.pl?codigo=', Line);
  275.         EndPos := pos(')">',Line)-1;
  276.         MovieAddress :=  copy(Line, StartPos, EndPos - StartPos);
  277.         StartPos := EndPos + 15;
  278.         StartPos :=  EndPos+4;
  279.         endpos:=pos('</A><BR>',Line);
  280.         Line:=Copy(Line,startpos,endpos);
  281.         findmoviename:=HTMLRemove(Line);
  282.         HTMLRemoveTags(FindMovieName);
  283.         HTMLDecode(FindMovieName);
  284.         PickTreeAdd(FindMovieName, BaseAddress + MovieAddress);
  285.         LineNr := LineNr + 1;
  286.       End;
  287.     until (LineNr<1);
  288.  
  289.  
  290.     if PickTreeExec(Address) then begin
  291.       AnalyzeFilmPage(Address);
  292.     end;
  293.     Page.Free;
  294.   end;
  295.   DisplayResults;
  296. end;
  297. begin
  298.   PickListClear;
  299.   MovieName := GetField(fieldOriginalTitle);
  300.   if Input('Import from www.7arte.net', 'Enter the title of the movie:', MovieName) then begin
  301.   //espaτo nπo sπo permitidos
  302.   MovieName := StringReplace(MovieName, ' ', '%20');
  303. //  AnalyzePage('http://babelfish.altavista.com/babelfish/urltrurl?lp=zh_en&url=www.7arte.net/cgi-bin/arquivos/search_orig.pl?proc='+MovieName,'http://babelfish.altavista.com/babelfish/urltrurl?lp=zh_en&url=www.7arte.net/cgi-bin/arquivos/search.pl?proc='+MovieName);
  304.  
  305. AnalyzePage('http://triumphpc.com/cgi-bin/nph-proxy.cgi/000000A/http/www.7arte.net/cgi-bin/arq_search_orig.pl?letra=&proc='+MovieName,'http://triumphpc.com/cgi-bin/nph-proxy.cgi/000000A/http/www.7arte.net/cgi-bin/arq_search.pl?proc='+MovieName);
  306.   end;
  307. end.
  308.  
  309.